import os
from lib.predicter import Predicter
import json
from lib.utils import parse_config_file, get_input_dataset

if __name__ == '__main__':
    dataset_name = get_input_dataset()
    config = parse_config_file(dataset_name)
    predicter = Predicter(**config)

    print("Start predicting...")
    metrics = predicter.predict()
    print(metrics)

    path = config['test']['metric_result_save_path']
    os.makedirs(path, exist_ok=True)
    with open(
        f"{path}/{config['model_name'].spilt('.')[0]}.json", "w"
    ) as f:
        json.dump(metrics, f, indent=4)
        print("Metrics saved!")
